USE [SecondBrain]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserAccounts_UserContacts]') AND parent_object_id = OBJECT_ID(N'[dbo].[UserAccounts]'))
ALTER TABLE [dbo].[UserAccounts] DROP CONSTRAINT [FK_UserAccounts_UserContacts]
GO

USE [SecondBrain]
GO

/****** Object:  Table [dbo].[UserAccount]    Script Date: 01/30/2012 11:17:50 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserAccounts]') AND type in (N'U'))
DROP TABLE [dbo].[UserAccounts]
GO

USE [SecondBrain]
GO

/****** Object:  Table [dbo].[UserAccount]    Script Date: 01/30/2012 11:17:50 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[UserAccounts](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](255) NOT NULL,
    [Password] [varchar](255) NULL,
	[UserContactId] [int] NOT NULL,
	[insertBy] [dbo].[UDT_CURRENT_USER] NOT NULL,
	[insertDate] [dbo].[UDT_CURRENT_DATETIME] NOT NULL,
	[updateBy] [dbo].[UDT_CURRENT_USER] NOT NULL,
	[updateDate] [dbo].[UDT_CURRENT_DATETIME] NOT NULL,
 CONSTRAINT [PK_UserAccounts] PRIMARY KEY NONCLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 80) ON [IDX]
) ON [DATA]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[UserAccounts]  WITH CHECK ADD  CONSTRAINT [FK_UserContacts_UserAccounts] FOREIGN KEY([UserContactId])
REFERENCES [dbo].[UserContacts] ([Id])
GO

ALTER TABLE [dbo].[UserAccounts] ADD  CONSTRAINT [DF_UserAccounts_insertBy]  DEFAULT (original_login()) FOR [insertBy]
GO

ALTER TABLE [dbo].[UserAccounts] ADD  CONSTRAINT [DF_UserAccounts_insertDate]  DEFAULT (getdate()) FOR [insertDate]
GO

ALTER TABLE [dbo].[UserAccounts] ADD  CONSTRAINT [DF_UserAccounts_updateBy]  DEFAULT (original_login()) FOR [updateBy]
GO

ALTER TABLE [dbo].[UserAccounts] ADD  CONSTRAINT [DF_UserAccounts_updateDate]  DEFAULT (getdate()) FOR [updateDate]
GO

